package d_decrator.b_design_pattern;

/**
 * Created by wug on 2016/6/22 0022.
 */
public class DoubleComponent extends Decorator {

    Decorator decorator;

    public DoubleComponent(Decorator decorator) {
        super(decorator);
        this.decorator = decorator;
    }

    @Override
    public String showDesc() {
        /*String desc = decorator.showDesc();
        int lastIndex = desc.lastIndexOf("\n");
        return  desc.substring(0, lastIndex) + "*2" + "\t" + getPrice() + "\n";*/
        return decorator.showDesc() + getDesc() + "\t" + getPrice() + "\n";
    }

    @Override
    public int showPrice() {
        return decorator.showPrice() + decorator.getPrice() -100;
    }

    @Override
    public int getPrice() {
        return decorator.getPrice()*2 - 100;
    }

    @Override
    public String getDesc() {
        return decorator.getDesc() + "*2";
    }
}
